package org.eenie.appseed.ui.counter

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
import org.eenie.appseed.R
import org.eenie.appseed.databinding.FragmentCounterBinding
import org.eenie.core.base.viewmodel.BaseBindingViewModelFragment


class CounterFragment : BaseBindingViewModelFragment<FragmentCounterBinding, CounterState, CounterViewModel>() {


    companion object {
        @JvmStatic
        fun newInstance() = CounterFragment()
    }

    override fun initUI(binding: FragmentCounterBinding) {

    }

    override fun providerViewModel(): CounterViewModel = activityViewModels<CounterViewModel>().value

    override fun renderUI(state: CounterState) {
        when (state) {
            is CounterState.OnCountChange -> {
                binding.tvCount.text = state.value.toString()
            }

            else -> {}
        }
    }

    override fun providerBinding(inflater: LayoutInflater, savedInstanceState: Bundle?) = FragmentCounterBinding.inflate(inflater)
}